//Written by Kyle Lowry
//Modified by Francisco "Kiko" Olvera

#pragma once

#include "Structures.h"
#include "Mesh.h"
#include "Card.h"
#include "SpriteInfo.h"

class Sprite;
class Tile;
class Board;

class Player
{
private:
	////////////////////////////////////////////////////////////////
	//Player character variables
	////////////////////////////////////////////////////////////////
	Tile*	CurrentTile;		//pointer to current tile
	Tile*	HomeSpace;			//The player character's position they start at is considered their homespace
	Board*	board;
	XY		TilePos;			//The player character's position on the current tile
	Mesh	mesh;				//player's mesh
	int		Orientation;		//The player character's orientation which can only be NORTH, EAST, SOUTH, WEST (which are enums)
	bool	Alive;				//whether the player is in the game or not

	int		numPlayerCards;		//Number of cards that the player currently has
	Card**	playerCards;		//A container of card objects (which protain to the player's artifact goal) that will be used for each player

	/* Just set as an int for testing purposes */
	int		Goal;				//The player character's current artifact that they are searching for

private:
	bool MoveRealNorth();
	bool MoveRealSouth();
	bool MoveRealEast();
	bool MoveRealWest();
public:
	Player();
	~Player(){}

	//////////////////////////////////////////////////////////////////////////
	// Name:		Init
	// Parameters:	Sprite* a_sprite -	A sprite object used to initialize
	//									and draw the appropriate sprites
	//									for each player
	// Return:		void
	// Description: This function is run when the player needs to have
	//				certain objects Initialized (such as the sprite).
	//////////////////////////////////////////////////////////////////////////
	void Init(char*, XY, int, Card**, int);

	//////////////////////////////////////////////////////////////////////////
	// Name:		SetTilePosition
	// Parameters:	XY - Struct that will decide the player character's
	//					 position on the current tile.
	// Return:		bool
	// Description: Set the player's position on the current tile.
	//////////////////////////////////////////////////////////////////////////
	bool SetTilePosition(XY);
	inline void SetOrientation(int direction)	{Orientation = direction;}

	//////////////////////////////////////////////////////////////////////////
	// Name:		Move
	// Parameters:	none
	// Return:		bool
	// Description: Change tile position and/or board position if
	//				necessary.
	//////////////////////////////////////////////////////////////////////////
	bool MoveNorth();
	bool MoveSouth();
	bool MoveEast();
	bool MoveWest();
	
	void ForceMoveNorth();
	void ForceMoveSouth();
	void ForceMoveEast();
	void ForceMoveWest();

	//////////////////////////////////////////////////////////////////////////
	// Name:		SetGoal
	// Parameters:	int - integer to represent the player's current artifact
	//					  that they are trying to reach
	// Return:		void
	// Description: Set the player's current artifact goal
	//////////////////////////////////////////////////////////////////////////
	void SetGoal(int);

	//////////////////////////////////////////////////////////////////////////
	// Name:		SetBoardPosition
	// Parameters:	XY - Struct that will decide the player character's
	//					 position on the board.
	// Return:		bool
	// Description: Set the player's position on the board.
	//////////////////////////////////////////////////////////////////////////
	void SetBoardPosition(Tile*);
	void SetBoardPosition(XY);

	void SetCards(Card**);
	bool isHome();


	bool Collect();
public:
	//gets
	inline Tile*	getCurrentTile()	{return CurrentTile;}
	inline bool		isAlive()			{return Alive;}
	inline Mesh*	getMesh()			{return &mesh;}

	//Used to get the current players cards to either shuffle or look at (for example in the search cards power-up)
	inline Card**	getCards()			{return playerCards;}

	//Used to get the current amount of cards the player has
	inline int		getNumCards()		{return numPlayerCards;}

public:
	void Draw();

	void DrawCards(Sprite*);

	void ShowCard();

	void ShowAllCards();

	void HideCard();

	void HideAllCards();
};